--- @param extension Package
--- @param HY HY_Utility
--- @param U Utility
return function(extension, HY, U)
    local hy_letty_whiterock = General:new(extension, "hy_letty_whiterock", "jin_k", 3, 3, General.Female)
    local coming_cold = fk.CreateSkill {
        name = "coming_cold",
    }
    coming_cold:addEffect(fk.Damaged, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(coming_cold.name) and data.to == player and #table.filter(player.room:getOtherPlayers(player), function(t)
                return not table.contains(t.sealedSlots, Player.JudgeSlot)
            end) > 0
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            local targets = room:askToChoosePlayers(player, {
                targets = table.filter(room:getOtherPlayers(player), function(t)
                    return not table.contains(t.sealedSlots, Player.JudgeSlot)
                end),
                min_num = 1,
                max_num = 1,
                skill_name = coming_cold.name,
                prompt = "coming_cold_prompt"
            })
            event:setCostData(self, targets)
            return #targets == 1
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            local target1 = event:getCostData(self)[1]
            local choices = { "coming_cold_choice1", "coming_cold_choice2" }
            if #table.filter(room:getOtherPlayers(target1), function(t)
                    return not t:isKongcheng()
                end) == 0 then
                table.removeOne(choices, "coming_cold_choice2")
            end
            local result = ""
            if #choices == 1 then
                result = choices[1]
            else
                result = room:askToChoice(player, {
                    choices = choices,
                    skill_name = coming_cold.name,
                    cancelable = false,
                })
            end
            if result == choices[1] then
                local cards = table.filter(table.map(room.draw_pile, function(id)
                    return Fk:getCardById(id)
                end), function(card)
                    return card.type == Card.TypeTrick and card.sub_type == Card.SubtypeDelayedTrick and table.every(target1:getCardIds("j"), function(_id)
                        return Fk:getCardById(_id).name ~= card.name
                    end)
                end)
                if #cards > 0 then
                    local card = table.random(cards)
                    room:moveCardTo(card, Card.PlayerJudge, target1, fk.ReasonPut, coming_cold.name, nil, nil, player)
                end
            else
                local target2 = room:askToChoosePlayers(player, {
                    targets = table.filter(room:getOtherPlayers(target1), function(t)
                        return not t:isKongcheng()
                    end),
                    min_num = 1,
                    max_num = 1,
                    skill_name = coming_cold.name,
                    prompt = "coming_cold_prompt2",
                    cancelable = false,
                })[1]
                if player ~= target2 then
                    HY.ReplaceHandCardToTempNew(player, target2:getCardIds("h"))
                end
                local cards = HY.AskForCard(player, 1, 1, false, coming_cold.name, table.every(target2:getCardIds("h"), function(id)
                    return Fk:getCardById(id).sub_type ~= Card.SubtypeDelayedTrick
                end), ".|.|.|.|.|delayed_trick", "coming_cold_prompt3")
                if #cards == 1 then
                    room:moveCardTo(cards, Card.PlayerJudge, target1, fk.ReasonPut, coming_cold.name, nil, nil, player)
                end
                if player ~= target2 then
                    HY.ReverseHandCardFromTempNew(player)
                end
            end
        end
    })
    coming_cold:addEffect("active", {
        target_num = 1,
        can_use = function(self, player)
            return player:usedEffectTimes(self.name, Player.HistoryPhase) < 1 and #table.filter(Fk:currentRoom().alive_players, function(t)
                return not table.contains(t.sealedSlots, Player.JudgeSlot) and t ~= player
            end) > 0
        end,
        card_filter = Util.FalseFunc,
        target_filter = function(self, player, to_select, selected, selected_cards)
            return #selected == 0 and table.contains(table.filter(Fk:currentRoom().alive_players, function(t)
                return not table.contains(t.sealedSlots, Player.JudgeSlot) and t ~= player
            end), to_select)
        end,
        prompt = function(self, player, selected_cards, selected_targets)
            return "coming_cold_prompt"
        end,
        on_use = function(self, room, skillUseEvent)
            local player = skillUseEvent.from
            local target1 = skillUseEvent.tos[1]
            local choices = { "coming_cold_choice1", "coming_cold_choice2" }
            if #table.filter(room:getOtherPlayers(target1), function(t)
                    return not t:isKongcheng()
                end) == 0 then
                table.removeOne(choices, "coming_cold_choice2")
            end
            local result = ""
            if #choices == 1 then
                result = choices[1]
            else
                result = room:askToChoice(player, {
                    choices = choices,
                    skill_name = coming_cold.name,
                    cancelable = false,
                })
            end
            if result == choices[1] then
                local cards = table.filter(table.map(room.draw_pile, function(id)
                    return Fk:getCardById(id)
                end), function(card)
                    return card.type == Card.TypeTrick and card.sub_type == Card.SubtypeDelayedTrick and table.every(target1:getCardIds("j"), function(_id)
                        return Fk:getCardById(_id).name ~= card.name
                    end)
                end)
                if #cards > 0 then
                    local card = table.random(cards)
                    room:moveCardTo(card, Card.PlayerJudge, target1, fk.ReasonPut, coming_cold.name, nil, nil, player)
                end
            else
                local target2 = room:askToChoosePlayers(player, {
                    targets = table.filter(room:getOtherPlayers(target1), function(t)
                        return not t:isKongcheng()
                    end),
                    min_num = 1,
                    max_num = 1,
                    skill_name = coming_cold.name,
                    prompt = "coming_cold_prompt2",
                    cancelable = false,
                })[1]
                if player ~= target2 then
                    HY.ReplaceHandCardToTempNew(player, target2:getCardIds("h"))
                end
                local cards = HY.AskForCard(player, 1, 1, false, coming_cold.name, table.every(target2:getCardIds("h"), function(id)
                    return Fk:getCardById(id).sub_type ~= Card.SubtypeDelayedTrick
                end), ".|.|.|.|.|delayed_trick", "coming_cold_prompt3")
                if #cards == 1 then
                    room:moveCardTo(cards, Card.PlayerJudge, target1, fk.ReasonPut, coming_cold.name, nil, nil, player)
                end
                if player ~= target2 then
                    HY.ReverseHandCardFromTempNew(player)
                end
            end
        end
    })
    local extending_cold = fk.CreateSkill {
        name = "extending_cold",
        tags = {
            Skill.Genetics,
        },
        dynamic_desc = function(self, player, lang)
            if player:getMark("extending_cold_mutation") ~= 0 then
                return "extending_cold_mutation"
            end
            return "extending_cold"
        end
    }
    extending_cold:addEffect(fk.AfterCardsMove, {
        can_trigger = function(self, event, target, player, data)
            return player:hasSkill(extending_cold.name) and table.any(data, function(move)
                return move.from and not move.from.dead and not table.contains(move.from.sealedSlots, Player.JudgeSlot) and table.any(move.moveInfo, function(info)
                    return Fk:getCardById(info.cardId).sub_type == Card.SubtypeDelayedTrick and info.fromArea == Card.PlayerJudge and
                        not table.contains(table.map(move.from:getCardIds("j"), function(id)
                            return Fk:getCardById(id).name
                        end), Fk:getCardById(info.cardId).name)
                end)
            end)
        end,
        on_cost = function(self, event, target, player, data)
            local room = player.room
            local cards = {}
            for _, move in ipairs(data) do
                if move.from and not move.from.dead and not table.contains(move.from.sealedSlots, Player.JudgeSlot) then
                    for _, info in ipairs(move.moveInfo) do
                        if Fk:getCardById(info.cardId).sub_type == Card.SubtypeDelayedTrick and info.fromArea == Card.PlayerJudge and not table.contains(table.map(move.from:getCardIds("j"), function(
                                id)
                                return Fk:getCardById(id).name
                            end), Fk:getCardById(info.cardId).name) then
                            table.insertIfNeed(cards, info.cardId)
                        end
                    end
                end
            end
            local cardNames = table.concat(table.map(cards, function(id)
                return Fk:getCardById(id):toLogString()
            end), ",")
            if player:getMark("extending_cold_mutation") ~= 0 then
                if room:askToSkillInvoke(player, {
                        skill_name = extending_cold.name,
                        prompt = "extending_cold_prompt_mutation:::" .. cardNames
                    }) then
                    event:setCostData(self, { "extending_cold_choice1:::" .. cardNames, cardNames })
                else
                    event:setCostData(self, { "Cancel" })
                end
            else
                local result = room:askToChoice(player, {
                    choices = { "extending_cold_choice1:::" .. cardNames, "extending_cold_choice2", "Cancel" },
                    skill_name = extending_cold.name
                })
                event:setCostData(self, { result, cardNames })
            end
            return event:getCostData(self)[1] ~= "Cancel"
        end,
        on_use = function(self, event, target, player, data)
            local room = player.room
            if event:getCostData(self)[1] == "extending_cold_choice1:::" .. event:getCostData(self)[2] then
                room:loseHp(player, 1)
                local moves = {}
                for _, move in ipairs(data) do
                    if move.from and not move.from.dead and not table.contains(move.from.sealedSlots, Player.JudgeSlot) then
                        for _, info in ipairs(move.moveInfo) do
                            local card = Fk:getCardById(info.cardId)
                            if card.sub_type == Card.SubtypeDelayedTrick and info.fromArea == Card.PlayerJudge and not table.contains(table.map(move.from:getCardIds("j"), function(
                                    id)
                                    return Fk:getCardById(id).name
                                end), card.name) then
                                table.insert(moves, {
                                    ids = { info.cardId },
                                    toArea = Card.PlayerJudge,
                                    to = move.from,
                                    from = room:getCardOwner(card),
                                    specialName = room:getCardOwner(card) and room:getCardOwner(card):getPileNameOfId(info.cardId) or "",
                                    moveReason = fk.ReasonPut,
                                    proposer = player,
                                    skillName = extending_cold.name,
                                })
                            end
                        end
                    end
                end
                room:moveCards(table.unpack(moves))
            else
                room:drawCards(player, 1, extending_cold.name)
            end
        end
    })
    extension:loadSkillSkels { coming_cold, extending_cold }
    hy_letty_whiterock:addSkills { "coming_cold", "extending_cold" }
    Fk:loadTranslationTable {
        ["hy_letty_whiterock"] = "蕾蒂",
        ["#hy_letty_whiterock"] = "冬日之寒",
        ["designer:hy_letty_whiterock"] = "黑曜人形",
        ["illustrator:hy_letty_whiterock"] = "猫車",
        ["cv:hy_letty_whiterock"] = "",

        ["coming_cold"] = "降凛",
        [":coming_cold"] = "在你受到伤害后或出牌阶段限一次，你可以选择一名其他角色并选择一项：1.将牌堆中随机一张延时锦囊牌置入其判定区；2.观看另一名角色的手牌，将其中一张延时锦囊牌置入其判定区。",
        ["coming_cold_prompt"] = "降凛：选择置入延时锦囊牌的目标",
        ["coming_cold_prompt2"] = "降凛：选择观看手牌的角色",
        ["coming_cold_prompt3"] = "降凛：选择一张延时锦囊牌",
        ["coming_cold_choice1"] = "从牌堆置入延时锦囊牌",
        ["coming_cold_choice2"] = "观看其他角色手牌",

        ["extending_cold"] = "延寒",
        [":extending_cold"] = "<a href='genetics_skill'>遗传技</a>，延时锦囊牌离开一名角色的判定区后，你可以选择一项：1.失去1点体力，将此牌置入其判定区；2.摸一张牌。突变：只能选择1选项。",
        [":extending_cold_mutation"] = "<a href='genetics_skill'>遗传技</a>，延时锦囊牌离开一名角色的判定区后，你可以选择一项：1.失去1点体力，将此牌置入其判定区；2.摸一张牌。<font color ='red'>突变</font>：只能选择1选项。",
        ["extending_cold_prompt_mutation"] = "延寒：你可以失去1点体力并将%arg置回判定区",
        ["extending_cold_choice1"] = "将%arg置回判定区",
        ["extending_cold_choice2"] = "摸一张牌",
    }
end
